<?php

$tcpServer = new Swoole\Server('127.0.0.1',9501,SWOOLE_PROCESS,SWOOLE_SOCK_TCP);


$tcpServer->set([
	'worker_num'=>4,
	'max_request'=>1000
]);


$tcpServer->on('connect',function($server,$fd,$reactor_id){

	echo "客户端 {$reactor_id} --- {$fd}上线\n";
});

$tcpServer->on('receive',function($server,$fd,$reactor_id,$data){

	$server->send($fd,"客户 {$reactor_id} 说： {$data}");
});

$tcpServer->on('close',function($server,$fd,$reactor_id){

	echo "客户 {$reactor_id} --- {$fd} 下线了\n";
});


$tcpServer->start();
